/**
  ******************************************************************************
  * @file    ds1302.h
  * @author  Dajin Li
  * @version V0.0.1
  * @date    08-08-2015 
  * @brief   Main program body
  *          
  ******************************************************************************
  * @attention
  *
  * <h2><center>&copy; KION(SZ) R&D Center
  *
  * Licensed under KION, (the "License");
  *
  ******************************************************************************
  */

/* Includes ------------------------------------------------------------------*/
#ifndef _DS1302_H_
#define _DS1302_H_

#define DS1302_SEC_WR_ADDR    0x80
#define DS1302_SEC_RD_ADDR    0x81

#define DS1302_MIN_WR_ADDR    0x82
#define DS1302_MIN_RD_ADDR    0x83


#define DS1302_HOUR_WR_ADDR   0x84
#define DS1302_HOUR_RD_ADDR   0x85

#define DS1302_DATE_WR_ADDR   0x86
#define DS1302_DATE_RD_ADDR   0x87

#define DS1302_MON_WR_ADDR    0x88
#define DS1302_MON_RD_ADDR    0x89

#define DS1302_DAY_WR_ADDR    0x8A
#define DS1302_DAY_RD_ADDR    0x8B

#define DS1302_YEAR_WR_ADDR   0x8C
#define DS1302_YEAR_RD_ADDR   0x8D

#define DS1302_CTRL_WR_ADDR   0x8E
#define DS1302_CTRL_RD_ADDR   0x8F

#define DS1302_CHARGER_WR_ADDR   0x90
#define DS1302_CHARGER_RD_ADDR   0x91

#define DS1302_RAM0_WR_ADDR   0xC0
#define DS1302_RAM0_RD_ADDR   0xC1

#define DS1302_RAM0_INIT_VAL  0xce


#define DS1302_PORT   GPIOE
#define DS1302_RST    GPIO_Pin_12      
#define DS1302_DATA   GPIO_Pin_13 
#define DS1302_CLK    GPIO_Pin_14 

extern  void  Write_Ds1302_Byte(u8 data1302);
extern  void  Write_Ds1302(u8 address,u8 dat);
extern  u8 Read_Ds1302_Byte(void);
extern  u8 Read_Ds1302(u8 address);
extern  void  Write_Ds1302_Bytes(u8 *pSecDa);
extern  void  Read_Ds1302_Bytes(u8 *pSecDa);
extern  void  Write_Ds1302register_Bytes(u8 *pReDa);
extern  void  Read_Ds1302register_Bytes(u8 *pReDa);
extern  void  Set1302_starttime(u8 *pSecDa) ;
extern  void  Get1302_ontime(u8 Gettimebuf[]) ;
extern  void  DS1302_writeymdhm(void);
extern  void  DS1302_Initial(void);
extern void DS1302_TimeShow(void);
extern void DS1302_DateShow(void);
extern void DS1302_TimeSet(void);
extern void ReadDateData(void);
extern void ReadYearData(void);
extern void ReadMonthData(void);
extern void ReadDayData(void);


#endif 

